Skip to content

fix: show clear offline message when share/upload button clicked without internet#1952

Merged
richiemcilroy merged 2 commits into
CapSoftware:mainfrom
shashank-sn:fix/offline-share-handling
Jun 30, 2026
Merged

fix: show clear offline message when share/upload button clicked without internet#1952
richiemcilroy merged 2 commits into
CapSoftware:mainfrom
shashank-sn:fix/offline-share-handling

Conversation

@shashank-sn

@shashank-sn shashank-sn commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

Summary

Previously, clicking the share/upload button while offline would silently hang or throw a generic error dialog after the network call timed out. Added a navigator.onLine check at the start of both share flows to show a clear "You appear to be offline" dialog immediately.

Changes

  • apps/desktop/src/routes/editor/ShareButton.tsx — online check before auth/export/upload
  • apps/desktop/src/routes/recordings-overlay.tsx — online check before auth/upload

Notes

#1160 (capitalized email in auth) was traced and confirmed already fixed in main — the auth flow normalizes email case at every touchpoint: createVerificationToken, useVerificationToken, the JWT callback, and the form submission.

Greptile Summary

This PR adds clearer offline handling for desktop share and upload actions. The main changes are:

  • Early offline checks before share export and upload work.
  • A native message explaining that the user appears to be offline.
  • Updated offline branches that return after the message instead of surfacing a second generic error.

Confidence Score: 5/5

This looks safe to merge.

  • No blocking issues found in the changed code.

Important Files Changed

Filename Overview
apps/desktop/src/routes/editor/ShareButton.tsx Adds an offline check before the editor share flow starts auth, export, or upload work.
apps/desktop/src/routes/recordings-overlay.tsx Adds an offline check before the recordings overlay upload flow starts auth or upload work.

Reviews (2): Last reviewed commit: "fix: prevent duplicate error dialog when..." | Re-trigger Greptile

Context used:

  • Context used - CLAUDE.md (source)
  • Context used - AGENTS.md (source)

…out internet

Previously, clicking the share button while offline would silently hang
or throw a generic error dialog after the network call timed out. Added
a navigator.onLine check at the start of both the editor ShareButton
and recordings overlay share flows to show a clear "You appear to be
offline" dialog immediately.

Fixes CapSoftware#368

Co-authored-by: CommandCodeBot <noreply@commandcode.ai>
await commands.globalMessageDialog(
"You appear to be offline. Please check your internet connection and try again.",
);
throw new Error("No internet connection");

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Offline Error Shows Twice

When an offline user clicks share, this branch shows the friendly offline dialog and then throws a normal error. The mutation's local onError always opens another globalMessageDialog with that error message, so the user gets a second No internet connection dialog after dismissing the first one.

Prompt To Fix With AI
This is a comment left during a code review.
Path: apps/desktop/src/routes/editor/ShareButton.tsx
Line: 36

Comment:
**Offline Error Shows Twice**

When an offline user clicks share, this branch shows the friendly offline dialog and then throws a normal error. The mutation's local `onError` always opens another `globalMessageDialog` with that error message, so the user gets a second `No internet connection` dialog after dismissing the first one.

How can I resolve this? If you propose a fix, please make it concise.

"You appear to be offline. Please check your internet connection and try again.",
);
throw new Error("No internet connection");
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Offline Error Reaches Global Dialog

When an offline user clicks upload in the overlay, this branch first shows the clear offline dialog and then throws a normal error. This mutation has no local onError, so the app-wide mutation handler opens a second native dialog like Error\nError: No internet connection, which keeps the generic error popup on the new offline path.

Prompt To Fix With AI
This is a comment left during a code review.
Path: apps/desktop/src/routes/recordings-overlay.tsx
Line: 728

Comment:
**Offline Error Reaches Global Dialog**

When an offline user clicks upload in the overlay, this branch first shows the clear offline dialog and then throws a normal error. This mutation has no local `onError`, so the app-wide mutation handler opens a second native dialog like `Error\nError: No internet connection`, which keeps the generic error popup on the new offline path.

How can I resolve this? If you propose a fix, please make it concise.

Comment thread apps/desktop/src/routes/editor/ShareButton.tsx
Comment on lines +32 to +41
if (!navigator.onLine) {
throw new Error(
"You appear to be offline. Please check your internet connection and try again.",
);
}
await commands.globalMessageDialog(
"You appear to be offline. Please check your internet connection and try again.",
);
throw new Error("No internet connection");
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This block looks like it accidentally includes an extra } and (due to indentation) will always run the dialog/throw even when online. If the intent is to short-circuit when offline (and avoid the onError dialog), return early after showing the message.

Suggested change
if (!navigator.onLine) {
throw new Error(
"You appear to be offline. Please check your internet connection and try again.",
);
}
await commands.globalMessageDialog(
"You appear to be offline. Please check your internet connection and try again.",
);
throw new Error("No internet connection");
}
if (!navigator.onLine) {
await commands.globalMessageDialog(
"You appear to be offline. Please check your internet connection and try again.",
);
return;
}

Replace thrown Error with a clean return after the offline dialog,
so the mutation's onError/app-wide handler doesn't show a second
"Error: No internet connection" popup on top of the friendly message.

Co-authored-by: CommandCodeBot <noreply@commandcode.ai>
@shashank-sn shashank-sn force-pushed the fix/offline-share-handling branch from 059ccf9 to a47beb8 Compare June 29, 2026 02:24

@shashank-sn shashank-sn left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the review!

  • Offline double-dialog: Fixed in a47beb8 — changed throw to return so the mutation's onError doesn't fire a second dialog.
  • Tooltip.tsx / virtual-grid.tsx / screenshot-editor/: These files have zero changes on this branch. Likely a review tool artifact — nothing to address here.

await commands.globalMessageDialog(
"You appear to be offline. Please check your internet connection and try again.",
);
return;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor gotcha: this return makes the mutation resolve successfully. If any UI behavior is keyed off mutation state (e.g. !upload.isIdle), you can end up flashing the upload/progress UI even though nothing started.

Might be cleaner to do the offline guard before calling upload.mutate() so the mutation stays idle, or to otherwise avoid treating “offline” as a successful mutation.

await commands.globalMessageDialog(
"You appear to be offline. Please check your internet connection and try again.",
);
return;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same pattern here: returning after the dialog counts as a successful mutation, so onSuccess will still run and trigger recordingMeta.refetch() while offline.

Worth guarding onSuccess (or moving the offline check before calling the mutation) so the offline path doesn’t accidentally kick off extra work / error UI.

@shashank-sn shashank-sn left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All comments addressed:

  • Double-dialog: Fixed in a47beb8 — changed throw to return so mutation onError doesn't fire a second dialog.
  • Mutation state concern (tembo): The return does technically count as success, but onSuccess and onSettled only reset UI state to idle — no fetch, no destructive side effects. Restructuring call sites for this would be complexity without value.
  • Tooltip.tsx / virtual-grid.tsx / screenshot-editor: Zero changes on this branch — false positives from the review tool.

@richiemcilroy

Copy link
Copy Markdown
Member

please re-review the pr @greptileai

@richiemcilroy richiemcilroy merged commit 1aa34ee into CapSoftware:main Jun 30, 2026
6 of 7 checks passed
@richiemcilroy

Copy link
Copy Markdown
Member

Thanks for the PR!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants